package hu.u_szeged.inf.ovrt.ioc_demo;

import hu.u_szeged.inf.ovrt.ioc_demo.controller.Controller;

import org.apache.log4j.xml.DOMConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


/**
 * Main, runnable class.
 */
public final class Main {
    private final ApplicationContext context;
    private static final Main INSTANCE = new Main();

    private Main() {
        DOMConfigurator.configure("conf/log4j.xml");
        context = new ClassPathXmlApplicationContext("classpath*:appconfig.xml");
    }

    private static Main getInstance() {
        return INSTANCE;
    }
    
    public ApplicationContext getContext(){
        return context;
    }

    /**
     * Main method, entry point of the application.
     * @param args input parameters
     */
    public static void main(String[] args) {
        Controller controller = (Controller) getInstance().getContext().getBean("controller");
        controller.run();
    }
}
